import React from 'react';
import ReactDOM from 'react-dom';
import {message} from 'antd';

import { createHashHistory } from 'History';

import { Router, Route, useRouterHistory, IndexRoute } from 'react-router';

import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';

import { Provider } from 'mobx-react';

import { WeaDebugRouteMenu } from 'ecCom';
WeaDebugRouteMenu.defaultProps.showRouteLev = 3;


import Module from './index';
import singleRoute from "./routes/single";
import singleStore from "./stores/single";

const routing = new RouterStore();

const allStore = window.edcStores = {
    routing,
    ...singleStore,
    ...Module.store,
};

const browserHistory = useRouterHistory(createHashHistory)({
    queryKey: '_key',
    basename: '/',
});
window.getActiveCell = () => {
    const sheet = workbookInstance.getActiveSheet();
    return sheet.getCell(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex());
}
window.showMessage = ()=>{
    message.success('发布成功', 10)
}
const history = syncHistoryWithStore(browserHistory, allStore.routing);
window.weaHistory = history;
const Root = () => (
    <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@9buchh`} {...allStore}>
        <Router ecId={`${this && this.props && this.props.ecId || ''}_Router@sxq1zm`} history={history}>
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@0fymua`} name='root' breadcrumbName='根路由' path='/' component={WeaDebugRouteMenu}>
                <IndexRoute ecId={`${this && this.props && this.props.ecId || ''}_IndexRoute@rrrshf`} path='edc/form/index' />
                {Module.Route}
                {singleRoute}
            </Route>
        </Router>
    </Provider>
);

ReactDOM.render(<Root ecId={`${this && this.props && this.props.ecId || ''}_Root@cgfzzd`} />, document.getElementById('container'));